<?php

/**
 * This is the model class for table "place".
 *
 * The followings are the available columns in table 'place':
 * @property string $place_id
 * @property string $place_name
 * @property string $alt_place_name
 * @property string $address_line1
 * @property string $address_line2
 * @property string $address_line3
 * @property string $address_line4
 * @property double $latitude
 * @property double $longitude
 * @property string $zone_id
 */
class Place extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Place the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'place';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zone_id', 'required'),
			array('latitude, longitude', 'numerical'),
			array('place_name, alt_place_name, address_line1, address_line2, address_line3, address_line4', 'length', 'max'=>255),
			array('zone_id', 'length', 'max'=>20),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('place_id, place_name, alt_place_name, address_line1, address_line2, address_line3, address_line4, latitude, longitude, zone_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'place_id' => 'Place',
			'place_name' => 'Place Name',
			'alt_place_name' => 'Alt Place Name',
			'address_line1' => 'Address Line1',
			'address_line2' => 'Address Line2',
			'address_line3' => 'Address Line3',
			'address_line4' => 'Address Line4',
			'latitude' => 'Latitude',
			'longitude' => 'Longitude',
			'zone_id' => 'Zone',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('place_id',$this->place_id,true);
		$criteria->compare('place_name',$this->place_name,true);
		$criteria->compare('alt_place_name',$this->alt_place_name,true);
		$criteria->compare('address_line1',$this->address_line1,true);
		$criteria->compare('address_line2',$this->address_line2,true);
		$criteria->compare('address_line3',$this->address_line3,true);
		$criteria->compare('address_line4',$this->address_line4,true);
		$criteria->compare('latitude',$this->latitude);
		$criteria->compare('longitude',$this->longitude);
		$criteria->compare('zone_id',$this->zone_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}